﻿using System.Data;
using ProgramMain.Framework;
using ProgramMain.Database;

namespace ProgramMain.Classifiers
{
    public partial class VertexTypeList : ProgramMain.Framework.BaseGridListCtl
    {
        public VertexTypeList()
        {
            InitializeComponent();
        }

        protected override void LoadData()
        {
            //прочитать данные из базы и заполнить датасет
            this.vertexTypesTableAdapter.SelectCommandTimeout = ProgramMain.Properties.Settings.Default.LongQueryTimeout;
            this.vertexTypesTableAdapter.Fill(this.simpleOpticNetDB.VertexTypes, null);
            UpdateStatusText(this.simpleOpticNetDB.VertexTypes);
        }

        protected override void UpdateData()
        {
            //внести изменения в базу
            this.vertexTypesTableAdapter.SetUpdateTimeout = ProgramMain.Properties.Settings.Default.LongQueryTimeout;
            this.vertexTypesTableAdapter.Update(this.simpleOpticNetDB.VertexTypes);
            UpdateStatusText(this.simpleOpticNetDB.VertexTypes);
        }

        override protected BaseModalDetailCtl CreateDetailDialog(BaseModalDetailCtl.ShowModeTypes pShowMode)
        {
            return new VertexTypeDetail();
        }

        override protected void PreCreateDetailDialog(BaseModalDetailCtl.ShowModeTypes pShowMode, DataRowView RowView)
        {
            if (RowView.Row is SimpleOpticNetDB.VertexTypesRow)
            {
                SimpleOpticNetDB.VertexTypesRow row = (SimpleOpticNetDB.VertexTypesRow) RowView.Row;
                //row.IsComplex = false;
                //row.IsDefault = false;
            }
        }

        public override BaseSecurity.SuperBool CheckSecurityAction(BaseSecurity.SecurityActionType ActionType, bool ShowWarning)
        {
            if (BaseSecurity.CheckSecuritySuperAction())
            {
                return BaseSecurity.SuperBool.True;
            }

            return BaseSecurity.SuperBool.False;
        }
    }
}
